<template>
  <div>
    <!-- 头部 -->
    <!-- 头部 -->
    <van-nav-bar title="网易严选" left-arrow>
      <template #left>
        <van-icon name="circle" size="70" color="black" />
      </template>
      <template #right>
        <van-icon name="search" size="70" class="top" color="black" />
        <van-icon name="cart" size="70" class="top" color="black" />
      </template>
    </van-nav-bar>
    <div class="header">{{ title }}</div>
    <!-- 内容 -->
    <div class="main">
      <div class="left">
        <List v-for="(item, index) in listL" :key="item.id" :item="item" />
      </div>
      <div class="right">
        <List v-for="(item, index) in listR" :key="item.id" :item="item" />
      </div>
    </div>
  </div>
</template>

<script>
import { reqCategorysList, reqCategoryDatas } from "../../api";
import List from "../../components/list";
export default {
  name: "categoryslist",
  components: { List },
  data() {
    return {
      listL: [],
      listR: [],
      title: "",
      id: "",
    };
  },
  methods: {
    async reqData() {
      this.title = this.$route.query.title;

      this.id = this.$route.query.id;
      let result = await reqCategorysList(this.id);
      this.listL = result.data.categoryItems.itemList.slice(
        0,
        result.data.categoryItems.itemList.length / 2
      );
      this.listR = result.data.categoryItems.itemList.slice(
        -result.data.categoryItems.itemList.length / 2
      );
    },
  },
  mounted() {
    this.reqData();
  },
};
</script>

<style lang="less" scoped>
.header {
  width: 100%;
  height: 1rem;
  background-color: white;
  text-align: center;
  line-height: 1rem;
  font-size: 0.4rem;
  border-bottom: 0.05rem solid red;
  color: red;
}
.main {
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
  margin-top: 0.2rem;
  background-color: white;
  .left {
    display: flex;
    flex-direction: column;
    width: 45%;
    // background-color: red;
    margin: 0 0.2rem;
  }
  .right {
    display: flex;
    flex-direction: column;
    width: 45%;
    // background-color: blue;
    margin: 0 0.2rem;
  }
}
</style>
